< previous page page_338 next page >

Page 338
0338-01.jpg
Figure 14.19
Black lines give the
indication of a pressed button.
1. Add a General page to the pages.
2. Place the Caption property on the General page.
3. Verify that the BackColor and ForeColor properties are on the StandardColor page.
4. Verify that the Font property is on the StandardFont page.
Testing the Color Button in a Program
At this point, the design of the ActiveX control is complete. You now are ready to test it in a program. You first need to add a Standard EXE project to the project group containing the ColorBtn. You then need to close the ColorBtn design window to make the control available to your project.
Next, you can draw the control on your form just like any other control. As you draw the button, you will see the typical rubber band box indicating the size of the control. When you release the mouse button, the control will be drawn using the default colors and caption (refer to Figure 14.18 to see how the control looks).
Setting the Button's Properties
After the button is placed on the form, set the values of the properties. You can, of course, set the properties from the Properties window. One point to notice is that if you placed a description in the Caption property when you defined it in the wizard, this description shows up in the area below the properties list when the Caption property is selected. This description is another way to help your users work with your custom control.
Another way to set the properties of your control is to use the Property Pages you created. The dialog box shown in Figure 14.20 enables you to set the Caption, BackColor, ForeColor, and Font properties of the control. The Paint event is fired whenever you close the Property Pages. At this time, the effects of the new properties are shown.
Writing Code for the Events
Writing code for an event procedure of the custom control is like writing code for any other event procedure. You can double-click the control to access the Code window in your test project and then begin typing code. Just to make sure the Click event of the ColorBtn control works, place a message box in the event procedure to announce that the button has been clicked. This code is shown in the following line:
MsgBox "You clicked the ColorBtn control."

 
< previous page page_338 next page >